/* led.c */
#define GPMCON		*((volatile unsigned long *)0x7F008820)
#define GPMDAT		*((volatile unsigned char *)0x7F008824)

#define LED_ON		1
#define LED_OFF		0

void led_init(void)
{
	GPMCON &= ~0xFFFF;			//将GPM0~3清零
	GPMCON |= 0x1111;			// 配置GPM0~3为输出
}

void led_write(const unsigned int led_num,const int led_status)
{
	if(led_num >= 4) return;
	
	if(led_status == LED_ON)
	{
		GPMDAT &= ~(0x01<<led_num);		//低电平点亮LED灯
	}
	else if(led_status == LED_OFF)
	{
		GPMDAT |= (0x01<<led_num);		//高电平熄灭LED灯
	}
}

void led_toggle(const unsigned int led_num)
{
	if(led_num >= 4) return;

	GPMDAT ^= (0x01<<led_num);
}
